package com.ilove.media.model;

import org.kalmeo.kuix.core.model.DataProvider;

public class CategoryList extends DataProvider {
	
	private static final String ID_PROPERTY = "id";
	private static final String NAME_PROPERTY = "categoryName";
	private static final String CODE_PROPERTY = "categoryCode";

	public int id = -1;

	public String categoryCode;

	public String categoryName;

	public void setId(int id) {
		this.id = id;
		dispatchUpdateEvent(ID_PROPERTY);
	}
	
	public void setCode(String categoryCode) {
		this.categoryCode = categoryCode;
		dispatchUpdateEvent(NAME_PROPERTY);
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String categoryName) {
		this.categoryName = categoryName;
		dispatchUpdateEvent(NAME_PROPERTY);
	}


	protected Object getUserDefinedValue(String property) {
		if (NAME_PROPERTY.equals(property)) {
			return this.categoryName;
		}
		if (CODE_PROPERTY.equals(property)) {
			return this.categoryCode;
		}
		
		if (ID_PROPERTY.equals(property)) {
			return Integer.toString(id);
		}
		return null;
	}
}